package com.myself.service;


import com.myself.entity.Permission;
import com.myself.entity.Role;
import com.myself.mapper.PermissionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:
 *
 * @Author: Liuzemin
 * @Date: 2020/7/10 14:11
 */
@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public Permission findById(Long id) {
        return permissionMapper.findById(id);
    }

    @Override
    public void create(Permission permission) {
        permissionMapper.create(permission);
    }

    @Override
    public void delete(Long id) {
        permissionMapper.deletePermission(id);
        permissionMapper.deleteRolePermission(id);
    }

    @Override
    public void update(Permission permission) {
        permissionMapper.update(permission);
    }

    @Override
    public List<Permission> findAll() {
        return permissionMapper.findAll();
    }

    @Override
    public void correlationRoles(Long permissionId, Long roleId) {
        permissionMapper.correlationRoles(permissionId, roleId);
    }

    @Override
    public List<Role> findRoleByPermissionId(Long id) {
        return permissionMapper.findRoleByPermissionId(id);
    }

    @Override
    public void deleteAllPermissionsRoles(Long id) {
        permissionMapper.deleteAllPermissionsRoles(id);
    }
}
